<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <script>
        // 数组排重
        var arr = [1, 5, 3, 5, 10, 0, 4, 2, 2, 4];
        document.write("原始数组为",arr,"<br>");
        for (var a = 0; a <= arr.length; a++) {
            // console.log(arr[a]);
            for (var i = 0; i <= arr.length; i++) {
                if (arr[a] == arr[i] && a !== i) {
                    arr.splice(i, 1);

                }
            }
        }
        document.write("排除重复：",arr,"<br>");


        // 数组从小到大排序
        function bubbleSort(arr){
    /*给每个未确定的位置做循环*/
    for(var unfix=arr.length-1; unfix>0; unfix--){
      /*给进度做个记录，比到未确定位置*/
      for(var i=0; i<unfix;i++){
        if(arr[i]>arr[i+1]){
          var temp = arr[i];
          arr.splice(i,1,arr[i+1]);
          arr.splice(i+1,1,temp);
        }
      }
    }
    document.write("从小到大为：",arr,"<br>");
  }
bubbleSort(arr);
//  输出最大值和最小值

var a = [1, 5, 3, 5, 10, 0, 4, 2, 2, 4];

document.write("最大值："+Math.max.apply(null, a) ,"<br>");//最大值
document.write("最小值："+Math.min.apply(null, a));//最小值



   
    </script>
</body>

</html>